package enregistrement;

import java.util.ArrayList;

import command.Command;

public class Enregistreur {

	private ArrayList<Command> listCommand;

	private ArrayList<Memento> listMemento;

	public ArrayList<Command> getListCommand() {
		return listCommand;
	}

	public void setListCommand(ArrayList<Command> listCommand) {
		this.listCommand = listCommand;
	}

	public ArrayList<Memento> getListMemento() {
		return listMemento;
	}

	public void setListMemento(ArrayList<Memento> listMemento) {
		this.listMemento = listMemento;
	}

	private boolean etat;

	public Enregistreur() {
		listMemento = new ArrayList<Memento>();
		listCommand = new ArrayList<Command>();
		etat = false;
	}

	public void setEtat(boolean etat) {
		this.etat = etat;

	}

	public boolean getEtat() {
		return etat;
	}

	public void ajouterCommand(Memento memento) {
		Command command = memento.getCommand();
		listMemento.add(memento);
		listCommand.add(command);
	}

	public ArrayList<Command> getCommandList() {
		return listCommand;
	}

	public void effacerListe() {
		listMemento.clear();
		listCommand.clear();
	}

	public int getListSize() {
		return listMemento.size();
	}

	public ArrayList<Memento> getMementoList() {
		return listMemento;
	}

	public void setMemento() {

	}

	public void demarrerE(boolean etat) {
		this.effacerListe();
		this.setEtat(true);
	}

	public void arreterE(boolean etat) {
		this.setEtat(false);
	}

	public void rejouer() {
		boolean etatE = this.getEtat();
		if (etatE == false) {
			for (int i = 0; i < this.getListSize(); i++) {
				Memento memento = this.getMementoList().get(i);
				System.out.println("le memento :"
						+ this.getCommandList().get(i));
				this.getCommandList().get(i).setMemento(memento);
				// System.out.println("le command :"
				// + this.getCommandList().get(i));
				this.getCommandList().get(i).execute();

			}
		}
	}
}
